n,k= map(int, input().split())
bucket=[0 for _ in range(k)]
for i in range(n):
    t=int(input())
    bucket[int(t%k)]+=1
ans=0
for i in range(k):
    j=int((k-i)%k)
    if j<i:
        break
    elif j==i:
        ans+=int(int(bucket[i]*(bucket[i]-1))/int(2))
    else:
        ans+=int(bucket[i]*bucket[j])
print(ans)